<?php 
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
defined('_JEXEC') or die('Retricted Access');
global $option, $jbconfig;
?>
<script type="text/javascript">
	function show_box_licensekey(){
		$('license_key').disabled = false;
		$('enable_proxy').disabled = false;
		$('submit_key').setStyle('display', '');
		//$('update_key').setStyle('display', 'none');
	}
	function hide_box_licensekey(){
		$('license_key').disabled = true;
		$('submit_key').setStyle('display', 'none');
		//$('update_key').setStyle('display', 'none');
	}
	function submit_license_key(){		
		if($('license_key').value.trim()=='') {
			alert('<?php echo JText::_('Please enter your License Key');?>');
			return false;
		}
		
		if( $('enable_proxy').checked ) {
			if($('proxy_address').value.trim()=='') {
				alert('<?php echo JText::_('Please enter Proxy address');?>');
				return false;
			}
			if($('proxy_port').value.trim()=='') {
				alert('<?php echo JText::_('Please enter Proxy port');?>');
				return false;
			}
		}
		
		
		return confirm('<?php echo JText::_('Are you sure you want to update to this new License Key?');?>');
	}
</script>

<form name="adminForm" action="index.php" method="post" enctype="multipart/form-data">
    <table width="100%">
		<tr>
			<td width="80%" valign="top">
				<div style="width:100%;">
					<?php echo $this->menu();?>
					<br/>
					
				</div>
			</td>
		</tr>
		<tr>
			<td width="100%">
				<center>				
				<fieldset>			
					<legend><?php echo JText::_('License Information');?></legend>
					<table align="center" class="admintable" width="50%">
						<tr>
							<td class="key" align="left"><?php echo JText::_('License Type')?>:</td>
							<td align="left"><?php echo (isset($jbconfig['license']) && $jbconfig['license']->get('type'))?get_license_type():JText::_('N/A');?></td>
						</tr>
						<tr>
							<td class="key" align="left"><?php echo JText::_('License for domains')?>:</td>
							<td align="left"><?php echo (isset($jbconfig['license']) && $jbconfig['license']->get('domains'))?$jbconfig['license']->get('domains'):JText::_('N/A');?></td>
						</tr>
						<tr>
							<td class="key" align="left">
								<?php if(isset($jbconfig['license']) && ($jbconfig['license']->get('expired_date')<time() || $jbconfig['license']->get('d13c3f7baed576768b11a714ef4d90e2')=='Waiting verify')){?>
									<?php echo JText::_('Status');?>
								<?php }else{?>
									<?php echo JText::_('Valid')?>:
								<?php }?>
							</td>
							<td align="left">
								<?php
								if(!isset($jbconfig['license']) || $jbconfig['license']->get('expired_date')==''){
									echo JText::_('N/A');
								}								
								elseif($jbconfig['license']->get('d13c3f7baed576768b11a714ef4d90e2')=='Waiting verify'){
									echo JText::_('Verification pending');						
								}
								elseif(date('Y', $jbconfig['license']->get('expired_date')) - date('Y')>0){
									if(  !$jbconfig['license']->get('expired_date') || ( date('Y', $jbconfig['license']->get('expired_date')) - date('Y')  > 10)  )	echo JText::_('Lifetime');
									else echo date('Y-m-d', $jbconfig['license']->get('expired_date'));
								}
								else{?>
									<?php if($jbconfig['license']->get('expired_date')>time()){?>
										<?php echo date('Y-m-d', $jbconfig['license']->get('expired_date'));?>
										(<?php echo (floor(($jbconfig['license']->get('expired_date')-time())/(60*60*24))+1). ' ' . JText::_('days');?>)
									<?php }else{?>
										<?php JError::raiseWarning(1, JText::_('Your license has expired. Therefore the system will be disabled. Please contact <a href="http://support.joomlart.com/">JoomlArt</a> for further assistance.'));?>
										<span class="" style="color: red; font-weight: bold;"><?php echo JText::_('Expired!');?>  </span>
									<?php }?>
										
								<?php }?>
							</td>
						</tr>
						
					</table>
					<br/>
					<table align="center">
						<tr>
							<td class="key" align="left">
								<?php if(isset($jbconfig['license']) && strtolower($jbconfig['license']->get('type'))=='trial'){?>
									<strong><?php echo JText::_('Trial License Key')?>:</strong>
								<?php }else{?>
									<strong><?php echo JText::_('License Key')?>:</strong>
								<?php }?>
								 [<a href="#" onclick="show_box_licensekey();"><?php echo JText::_('Update License Key')?></a>]
							</td>
						</tr>
						<tr>
							<td align="left">								
								<textarea rows="5" id="license_key" name="license_key" cols="80" <?php if($this->key!=''){?>disabled="disabled"<?php }?>><?php echo $this->key;?></textarea>
							</td>
						</tr>
						<?php if ( function_exists ( 'curl_version' ) ) { ?>
						<tr>
							<td align="left">								
								<input type="checkbox" onchange="if(this.checked){ $('proxy-box').setStyle('display', 'block')} else{ $('proxy-box').setStyle('display', 'none')}" value="1" name="enable_proxy" id="enable_proxy" />
								<label for="enable_proxy"><?php echo JText::_('Use a proxy server for your LAN')?></label>
								<br/>
								
								<table id="proxy-box" style="padding-left: 25px; display:none;">
									<tr>
										<td><label for="proxy_address"><?php echo JText::_('Address')?>:</label></td>
										<td><input type="text" value="<?php echo JRequest::getVar('proxy_address', '');?>" size="30" name="proxy_address" id="proxy_address"/> </td>
									</tr>
									<tr>
										<td><label for="proxy_port"><?php echo JText::_('Port')?>:</label></td>
										<td><input type="text" value="<?php echo JRequest::getVar('proxy_port', '');?>" size="5" name="proxy_port" id="proxy_port"/></td>
									</tr>
									<tr>
										<td><label for="proxy_user"><?php echo JText::_('User')?>:</label></td>
										<td><input type="text" value="<?php echo JRequest::getVar('proxy_user', '');?>" size="30" name="proxy_user" id="proxy_user"/></td>
									</tr>
									<tr>
										<td><label for="proxy_pass"><?php echo JText::_('Password')?>:</label></td>
										<td><input type="text" value="<?php echo JRequest::getVar('proxy_pass', '');?>" size="30" name="proxy_pass" id="proxy_pass"/></td>
									</tr>
									<input type="hidden" name="proxy_type" value="CURLPROXY_HTTP"/>
								</table>								 							
							</td>
						</tr>
						<?php } ?>
						<tr id="submit_key" <?php if($this->key!=''){?>style="display:none" <?php }?>>
							<td class="key" align="right">
								<strong><input type="submit"  value="<?php echo JText::_('Send Request')?>" onclick="return submit_license_key();"/> </strong>
								<strong><input type="reset"  value="<?php echo JText::_('Cancel')?>" onclick="return hide_box_licensekey();"/> </strong>
							</td>
						</tr>
					</table>
					 
				</fieldset> 
				</center>
			</td>
		</tr>
	</table>
<input type="hidden" name="option" value="<?php echo $option; ?>" />	
<input type="hidden" name="view" value="jajobboard" />	
<input type="hidden" name="task" value="reissue" />	

</form>
